<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="it.com.chen.malavolta.jingsen.entities.*, javax.naming.*" %>
<%@page import="java.util.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    	               "http://www.w3.org/TR/html4/loose.dtd">

<%!	private BookManagerRemote bm = null;
	public void jspInit() {
		try {
			InitialContext ic = new InitialContext();
			bm = (BookManagerRemote)ic.lookup(BookManagerRemote.class.getName());
		} catch (Exception e) {
			System.out.println("Cannot create bean" + e.getMessage());
		}
	}
	
	public void jspDestory() {
		if (bm != null)
			bm = null;
	}
	
%>
<html>
  <head>
    	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    	<title>Show Books</title>

<style type="text/css">
<!--
.STYLE3 {font-size: 16px; font-weight: bold; }
-->
</style>
</head>

<body>
<%

%>
<h1>Show Books</h1>
<hr />
<table width="426" border="1">
  <tr>
    <td width="116"><div align="center"><span class="STYLE3">Book Id </span></div></td>
    <td width="130"><div align="center"><span class="STYLE3">Book IBSN</span></div></td>
    <td width="150"><div align="center"><span class="STYLE3">Book Name</span></div></td>
    <td width="106"><div align="center"><span class="STYLE3">Author</span></div></td>
  </tr>
  <%
	List<Book> list = bm.getAllBookName();
  if (list == null) {
	  out.println("cannot be found any records!");
	  
  } else {
	  out.println("List length is :" + list.size());
    for (int i=0; i<list.size();i++) {
    	Book b = list.get(i);    	
    	%>
  <tr>
    <td><%=b.getId() %></td>
    <td><%=b.getBook_ISBN() %></td>
    <td><%=b.getName() %></td>
    <td><%=b.getAuthor() %></td>
  </tr>
  <%}} %>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
<p>&nbsp;</p>
</body>

</html>